<template >
  <div class="box">
    <el-container>
      <el-header>
        <div class="top">
          <div class="box-left">
            <img class="img" src="../assets/1.jpg" alt="">
            课堂在线后台管理系统
          </div>
          <div class="box-right"> 欢迎 <br>
            <el-dropdown>
              <span class="el-dropdown-link">
                <span class="user">{{user}}</span><i class="el-icon-arrow-down el-icon--right"></i>
              </span>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item><span @click="msg">个人信息</span> </el-dropdown-item>
                <el-dropdown-item> <span @click="logout">退出登录</span> </el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>

          </div>
        </div>
      </el-header>
      <el-container>
        <el-aside :width="iscollapse?'60px':'200px'">
          <el-menu :collapse-transition="false" :collapse="iscollapse" :default-active="active_menu"
            @select="selectactive" router>
            <el-menu-item v-show="!iscollapse" @click="close"><i class="el-icon-s-fold"></i></el-menu-item>
            <el-menu-item v-show="iscollapse" @click="open"><i class="el-icon-s-unfold"></i></el-menu-item>
            <el-menu-item index="/menu/">
              <i class="el-icon-s-home" style="margin-right:10px"></i><span
                  class="span">首页</span> 
            </el-menu-item>
            <el-submenu index="2">
              <template slot="title">
                <i class="iconfont icon-tubiaozhizuomoban" style="margin-right:10px"></i><span class="span">资金管理</span>
              </template>
              <el-menu-item-group>
                <el-menu-item index="/menu/money"><i class="iconfont icon-zijinliuzhuan" style="margin-right:10px"></i>
                  <span class="span">资金流水</span> </el-menu-item>
              </el-menu-item-group>
            </el-submenu>
            <el-submenu index="3">
              <template slot="title">
                <i class="el-icon-menu" style="margin-right:10px"></i><span class="span">信息管理</span>
              </template>
              <el-menu-item-group>
                <el-menu-item index="/menu/info"> <span class="span">信息列表</span> </el-menu-item>
              </el-menu-item-group>
            </el-submenu>
          </el-menu>
        </el-aside>
        <el-main>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>
<script>
export default {
  data() {
    return {

      iscollapse: true,
      user: "",
      visible: false,
      active_menu: '/menu/',
    };
  },
  mounted() {
    this.user = localStorage.getItem("user") || "";
   this.active_menu = localStorage.getItem('active_menu')

  },
  methods: {
    selectactive(index) {
      console.log(index);
      localStorage.setItem('active_menu', index)
    },
    close() {
      this.iscollapse = true
    },
    open() {
      this.iscollapse = false
    },
    logout() {
      localStorage.removeItem("token");
      this.$router.push("/");
    },

    msg() {
      this.$notify({
        title: '提示',
        message: '个人信息',
        type: 'warning'
      });
    }
  },
};
</script>
<style lang="css">
.el-header {
  padding: 0;
  height: 50px !important;
}

.box,
.el-container,
.el-aside {
  height: 100%;
}

.top {
  width: 100%;
  height: 50px;
  background-color: #324057;
  display: flex;
  justify-content: space-between;
  /* line-height: 50px; */
}

.box-left {
  display: flex;
  font-size: 25px;
  color: white;
  font-weight: 800;
  line-height: 50px;
}

.box-right {
  color: white;
  line-height: 15px;
  text-align: center;
  margin-top: 5px;
  margin-right: 30px;
}

.user {
  color: #409eff;
}

.el-aside {
  /* width: 200px; */
  background-color: #324057;
  /* margin-top: -10px; */
}

.el-menu {
  background-color: #324057;
  /* color: white; */
}

.img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  margin: 5px;
}

.span {
  color: white;
}

.el-submenu__title:hover {
  background: #444;
}

.el-submenu__title template:hover {
  background: #444;
}

.el-menu-item:focus,
.el-menu-item:hover {
  background: #444;
}
</style>